import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/14 9:39
 * @description 二分查找呗，排序都不要，
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int hIndex(int[] citations) {
        int n = citations.length;
        int l = 0, r = n - 1;
        while (l <= r) {
            int mid = (l + r) / 2;
            if (citations[mid] >= n - mid) {
                r = mid - 1;
            }else {
                l = mid + 1;
            }
        }
        return n - l;
    }
}
